package game.poker.holdem.entity;

import game.poker.holdem.card.CommunityCards;

import java.util.ArrayList;
import java.util.List;

public class Table {
    
    private final int MAX_PLAYERS;
    
    private Dealer dealer;
    private List<Player> players;
    
    private CommunityCards communityCards;
    
    public Table(Dealer dealer) {
        this.dealer = dealer;
        dealer.setTable(this);
        MAX_PLAYERS = 5;
        players = new ArrayList<Player>();
        communityCards = new CommunityCards();
    }
    
    public boolean removePlayer(Player player) {
        return players.remove(player);
    }
    
    public boolean addPlayer(Player player) {
        if(!(players.size() < MAX_PLAYERS)) {
            return false;
        }
        players.add(player);
        return true;
    }

    public Dealer getDealer() {
        return dealer;
    }

    public void setDealer(Dealer dealer) {
        this.dealer = dealer;
    }

    public List<Player> getPlayers() {
        return players;
    }

    public void setPlayers(List<Player> players) {
        this.players = players;
    }

    public CommunityCards getCommunityCards() {
        return communityCards;
    }

    public void resetCommunityCards() {
        this.communityCards = new CommunityCards();
    }
    
    public boolean isSeatAvailable() {
        return players.size() < MAX_PLAYERS;
    }
}
